230 IF N/2 < > INT(N/2) THEN PRINT "MUST BE AN EVEN NUMBER.": GOTO 220
235 ONERR GOTO 500
240 H = (B -A)/N
250 Y = FN A(A)
260 K = 4
270 FOR C = A +H TO (B -H -H/10) STEP H
280 Y = Y +K * FN A(C)
290 K = K -2: IF K = 0 THEN K = 4
300 NEXT
310 Y = Y + FN A(B)
320 R = Y *(H/3)
330 PRINT : PRINT "THE RESULT OF INTEGRATING THE FUNCTION": PRINT " F(X) = ";F$: PRINT "FROM "A" TO "B" IS:"
335 PRINT " ";R
340 PRINT
350 INPUT "TRY SAME FUNCTION WITH DIFFERENT PARAMETERS? (Y/N) ?";I$
360 IF LEFT$(I$,1) = "Y" THEN RUN
370 PRINT : INPUT "TRY A DIFFERENT FUNCTION? (Y/N) ?";I$
380 IF LEFT$(I$,1) = "Y" THEN 1070
390 PRINT : PRINT "BYE.": END
500 REM ONERR
507 PRINT
510 I = PEEK(222)
512 POKE 216,0
515 IF I = 107 OR I = 163 OR I = 176 OR I = 191 OR I = 224 THEN I = 16
520 IF I = 16 THEN PRINT "THE FUNCTION:": PRINT " F(X) = ";F$: PRINT "CONTAINS A SYNTAX ERROR.": PRINT : GOTO 370
530 IF I = 53 OR I = 133 THEN PRINT "THE FUNCTION IS NOT CONTINUOUS OVER THE RANGE SPECIFIED.": PRINT : GOTO 350
540 IF I = 69 OR I = 77 THEN PRINT "SORRY. THIS PROBLEM CAUSES AN OVERFLOW OF THE SYSTEM.": PRINT : GOTO 350
550 IF I = 255 THEN STOP
560 PRINT "UNFORSEEN ERROR (CODE #"I": SEE": PRINT "PAGE 136 OF APPLESOFT REFERENCE MANUAL)": PRINT "THERE MAY BE A BUG IN THE PROGRAM. EVENI'M NOT PERFECT.": PRINT : GOTO 350
1000 REM
1010 HOME : PRINT
1015 HTAB 3
1020 PRINT "SIMPSON'S RULE NUMERICAL INTEGRATION"
1030 PRINT : PRINT " BY DANIEL TOBIAS SEPT. 1982"
1040 PRINT
1050 INPUT " INSTRUCTIONS (Y/N)? ";I$
1060 IF LEFT$(I$,1) = "Y" THEN GOSUB 5000
1070 HOME : PRINT
1080 PRINT "ENTER THE FUNCTION USING NORMAL BASIC SYMBOLS (E.G. 'X SQUARED' IS REPRESENTED";
1090 PRINT "AS X^2)."
1100 PRINT : INPUT "F(X) = ";FF$
1105 IF FF$ = "" THEN 1100
1110 PRINT D$"OPEN EXEC.SIMP"
1120 PRINT D$"WRITE EXEC.SIMP"
1130 PRINT "40 F$="; CHR$(34);FF$; CHR$(34)
1140 PRINT "50 DEF FN A(X)=";FF$
1145 PRINT "RUN 1180"
1150 PRINT D$"CLOSE"
1160 PRINT D$"EXEC EXEC.SIMP"
1170 END
1180 PRINT CHR$(4)"DELETE EXEC.SIMP": RUN
5000 REM INSTRUCTIONS
5010 HOME
5020 PRINT : PRINT "THIS PROGRAM ESTIMATES THE NUMERICAL"